import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 26727
 * Date: 2025-06-24
 * Time: 23:30
 */
public class Test4 {

    public static void moveZero(int[] num) {
        for(int left = -1, right = 1; right < num.length; right++) {
            if(num[right] != 0) {
                left++;
                int tmp = num[left];
                num[left] = num[right];
                num[right] = tmp;
            }
        }
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] num = new int[n];
        for(int i = 0; i < n; i++) {
            num[i] = sc.nextInt();
        }
        moveZero(num);
        System.out.println(Arrays.toString(num));
    }
}
